mui.init();

function homeService($scope, $http) {
	dateTime.addEventListener('tap', function() {
		var optionsJson = this.getAttribute('data-options') || '{}';
		var options = JSON.parse(optionsJson);
		var picker = new mui.DtPicker(options);
		picker.show(function(rs) {
			$scope.serviceTime = rs.text;
			$scope.$apply($scope.serviceTime);
			picker.dispose();
		});
	}, false);
	$scope.sub = function() {
		if (localStorage.headName == '上门试衣') {
			if (!$scope.serviceRemark || !$scope.serviceRequirement || !$scope.servicePhone || !$scope.serviceTime) {
				mui.toast('请您完善信息后再提交');
				return;
			} else {
				param = "type=" + 0 + "&account=" + readData(localStorage.phone) + "&guideId=" + readData(localStorage.guideId) + "&remark=" + "商品描述：" + $scope.serviceRemark + ";备选目标：" + $scope.serviceRequirement + "&serviceMethod=" + 0 + "&serviceAddr=" + $scope.servicePhone + "&phone=" + readData(localStorage.phone) + "&otherRequirement=" + $scope.serviceRequirement + "&serviceTime=" + $scope.serviceTime + "&serviceId=" + 1;
			}
		}
		if (localStorage.headName == '定制改衣') {
			if (!$scope.serviceRemark || !$scope.serviceRequirement || !$scope.serviceTime) {
				mui.toast('请您完善信息后再提交');
				return;
			} else {
				param = "type=" + 0 + "&account=" + readData(localStorage.phone) + "&guideId=" + readData(localStorage.guideId) + "&remark=" + "商品描述：" + $scope.serviceRemark + ";备选目标：" + $scope.serviceRequirement + "&serviceMethod=" + 1 + "&otherRequirement=" + $scope.serviceRequirement + "&phone=" + readData(localStorage.phone) + "&serviceTime=" + $scope.serviceTime + "&serviceId=" + 2;
			}
		}
		url = getUrl("63service");
		headerJson = getHeader();
		$http({
			method: 'POST',
			url: url,
			headers: headerJson,
			timeout: 10000,
			data: param
		}).success(function(data, status, headers, config) {
			if (data.code == "0") {
				mui.toast('创建成功');
				setTimeout(function() {
					plus.webview.currentWebview().opener().close();
				}, 1000)
			} else {
				mui.alert('网络连接异常，请稍后重试' + data.code, '提示', function() {});
			}
		}).error(function(data) {
			console.log('上门试衣网络连接异常');
		});
	}
}